package com.tjmc.recruit.admin.controller;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tjmc.recruit.admin.api.entity.WebBasicConfEntity;
import com.tjmc.recruit.admin.service.WebBasicConfService;
import com.tjmc.recruit.common.core.util.R;
import com.tjmc.recruit.common.log.annotation.SysLog;
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
import com.pig4cloud.plugin.excel.annotation.RequestExcel;

import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import com.tjmc.recruit.common.security.annotation.HasPermission;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Objects;

/**
 * 网站基础信息配置
 *
 * @author recruit
 * @date 2024-11-22 09:53:14
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/webBasicConf" )
@Tag(description = "webBasicConf" , name = "网站基础信息配置管理" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class WebBasicConfController {

    private final WebBasicConfService webBasicConfService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param webBasicConf 网站基础信息配置
     * @return
     */
    @Operation(summary = "分页查询" , description = "分页查询" )
    @GetMapping("/page" )
    public R getWebBasicConfPage(@ParameterObject Page page, @ParameterObject WebBasicConfEntity webBasicConf) {
        LambdaQueryWrapper<WebBasicConfEntity> wrapper = Wrappers.lambdaQuery();
        return R.ok(webBasicConfService.page(page, wrapper));
    }


    /**
     * 通过条件查询网站基础信息配置
     * @param webBasicConf 查询条件
     * @return R  对象列表
     */
    @Operation(summary = "通过条件查询" , description = "通过条件查询对象" )
    @GetMapping("/details" )
    public R getDetails(@ParameterObject WebBasicConfEntity webBasicConf) {
        return R.ok(webBasicConfService.list(Wrappers.query(webBasicConf)));
    }

    /**
     * 新增网站基础信息配置
     * @param webBasicConf 网站基础信息配置
     * @return R
     */
    @Operation(summary = "新增网站基础信息配置" , description = "新增网站基础信息配置" )
    @SysLog("新增网站基础信息配置" )
    @PostMapping
    public R save(@RequestBody WebBasicConfEntity webBasicConf) {
        return R.ok(webBasicConfService.save(webBasicConf));
    }

    /**
     * 修改网站基础信息配置
     * @param webBasicConf 网站基础信息配置
     * @return R
     */
    @Operation(summary = "修改网站基础信息配置" , description = "修改网站基础信息配置" )
    @SysLog("修改网站基础信息配置" )
    @PutMapping
    public R updateById(@RequestBody WebBasicConfEntity webBasicConf) {
        return R.ok(webBasicConfService.updateById(webBasicConf));
    }

    /**
     * 通过id删除网站基础信息配置
     * @param ids id列表
     * @return R
     */
    @Operation(summary = "通过id删除网站基础信息配置" , description = "通过id删除网站基础信息配置" )
    @SysLog("通过id删除网站基础信息配置" )
    @DeleteMapping
    public R removeById(@RequestBody Integer[] ids) {
        return R.ok(webBasicConfService.removeBatchByIds(CollUtil.toList(ids)));
    }

}
